# -*- coding: utf-8 -*-
# @Time: 2021/11/27 16:24
# @Author: lijinxi
# @File    : executing_time.py
# @desc

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

mpl.rcParams["axes.unicode_minus"] = False

# 柱高信息
Y = [11.07, 22.12, 43.83, 87.17]
Y3 = [11.84, 26.90, 52.21, 99.23]
X = np.arange(len(Y))

tick_label = ['200', '400', '800', '1600']
fig = plt.figure()
ax2 = fig.add_subplot(111)
plt.xlabel("Number of Requests", fontsize=18)
plt.ylabel("Time(s)", fontsize=18)

p6 = ax2.plot([200, 400, 800, 1600], Y3, color='g', marker='D',
              markersize=10, markerfacecolor='none', ls='--', label='NBS')
p7 = ax2.plot([200, 400, 800, 1600], Y, color='r', marker='v', markersize=10,
              markerfacecolor='none', ls='--', label='KSP(K=3)')
plt.legend(loc=1, fontsize=8, frameon=False, ncol=2)
# ax2.legend([p6,],['K=5',],loc=9,fontsize=6)
ax2.tick_params(labelsize=16)  # 刻度字体大小13
plt.xticks([200, 400, 800, 1600], tick_label)
plt.ylabel("Time(s)", fontsize=18)
plt.axhline(y=20, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=40, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=60, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=80, color='lightgray', ls=':', linewidth=1)
plt.legend(fontsize=18, frameon=False, ncol=2)
plt.savefig('time.pdf', bbox_inches='tight')
plt.show()
